using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using BL;
using BO;

namespace AnimalFarm.Product_manage
{
    public partial class AddBulkProduct : Telerik.WinControls.UI.RadForm
    {
        private int farmerID;
        B_BulkProduct B_bulkProduct = new B_BulkProduct();
        public int FarmerID
        {
            get { return farmerID; }
            set { farmerID = value; }
        }
        public AddBulkProduct()
        {
            InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void btnAddproduct_Click(object sender, EventArgs e)
        {
            string productName = txtProductName.Text;
            if (!String.IsNullOrEmpty(productName))
            {
                BulkProduct_Info bulkProduct = new BulkProduct_Info();
                bulkProduct.BulkProductName = productName;
                bulkProduct.FarmID = FarmerID;

                bool isOk = B_bulkProduct.CreateOneBulkProduct(bulkProduct);
                if (isOk)
                {
                    MessageBox.Show(this, "Adding product is successful", "Product adding", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtProductName.Text = "";
                    txtProductName.Focus();
                }
                else
                    MessageBox.Show(this, "Adding product is fail", "Product adding", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }else
                MessageBox.Show(this, "The product name can not be empty", "Product adding", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
}
